package com.higgins.client.components;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.logging.Logger;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.higgins.client.GreetingService;
import com.higgins.client.GreetingServiceAsync;
import com.higgins.client.dataModel.CoveringLetterDTO;
import com.higgins.client.dataModel.LawFirmDTO;
import com.higgins.client.dataModel.StatusDTO;
import com.higgins.client.generic.components.GenericColumns;
import com.higgins.client.generic.components.GenericColumn;

public class RecipientColumns extends GenericColumns	{
	private static final Logger log = Logger.getLogger(RecipientColumns.class.getName());
	private final GreetingServiceAsync greetingService = GWT
			.create(GreetingService.class);

	public RecipientColumns()	{
		super();
		initialiseColumns();
	}
	private void initialiseColumns()	{
		GenericColumn genericColumn = new GenericColumn();
		genericColumn.setTitle("ID");
		genericColumn.setIndex(0);
		genericColumn.setType(Integer.class);
		genericColumn.setWidth(25);
		genericColumn.setEditable(false);
		addColumn(genericColumn);

		genericColumn = new GenericColumn();
		genericColumn.setTitle("Name");
		genericColumn.setIndex(1);
		genericColumn.setType(String.class);
		genericColumn.setWidth(300);
		genericColumn.setEditable(true);
		addColumn(genericColumn);
		
		LawFirmColumn lawFirmColumn = new LawFirmColumn();
		lawFirmColumn.setTitle("Law Firm");
		lawFirmColumn.setIndex(2);
		lawFirmColumn.setType(LawFirmDTO.class);
		lawFirmColumn.setWidth(150);
		lawFirmColumn.setEditable(true);
		lawFirmColumn.loadList();
		addColumn(lawFirmColumn);
		
		
/*		genericColumn = new GenericColumn();
		genericColumn.setTitle("Law Firm");
		genericColumn.setIndex(2);
		genericColumn.setType(LawFirmDTO.class);
		genericColumn.setWidth(200);
		genericColumn.setEditable(true);
		setList(genericColumn);
		addColumn(genericColumn);	*/
		
		genericColumn = new GenericColumn();
		genericColumn.setTitle("Address");
		genericColumn.setIndex(3);
		genericColumn.setType(String.class);
		genericColumn.setWidth(200);
		genericColumn.setEditable(true);
		addColumn(genericColumn);
		
		genericColumn = new GenericColumn();
		genericColumn.setTitle("Comment");
		genericColumn.setIndex(4);
		genericColumn.setType(String.class);
		genericColumn.setWidth(200);
		genericColumn.setEditable(true);
		addColumn(genericColumn);
		
		genericColumn = new GenericColumn();
		genericColumn.setTitle("Firm Status");
		genericColumn.setIndex(5);
		genericColumn.setType(String.class);
		genericColumn.setWidth(50);
		genericColumn.setEditable(false);
		addColumn(genericColumn);

		genericColumn = new GenericColumn();
		genericColumn.setTitle("Recipient");
		genericColumn.setIndex(6);
		genericColumn.setType(StatusDTO.class);
		genericColumn.setWidth(50);
		genericColumn.setEditable(false);
		addColumn(genericColumn);
		
	}
	
	private void setList(GenericColumn genericColumn)	{
//		GenericColumn column = genericColumn;
//		retrieveCoveringLetterDTOs(column);		
	}
/*
	private void retrieveCoveringLetterDTOs(final GenericColumn column)	{
		try {
			greetingService.retrieveCoveringLetters(new AsyncCallback<List<CoveringLetterDTO>>()	{
					@Override
					public void onFailure(Throwable caught) {
						log.info("StrategyColumns: " + caught.toString());
					}

					@Override
					public void onSuccess(List<CoveringLetterDTO> result) {
//						List<String> list = new ArrayList<String>();
//						for (CoveringLetterDTO coveringLetterDTO:result)	{
//							list.add(coveringLetterDTO.getName());
//						}
						column.setList(result);
					}
				});
		} catch (IllegalArgumentException e) {
			log.info("StrategyColumns: " + e.toString());
		}	}		
*/
}
